package com.kuangjia.student_ems.dto;

import com.kuangjia.student_ems.entity.SalaryScheme;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;

@Data
public class SalarySchemeDTO {
    private Long id;
    private String name;
    private Long positionId;
    private String positionName;
    private String salaryType;
    private BigDecimal baseSalary;
    private BigDecimal performanceRate;
    private BigDecimal hourlyRate;
    private BigDecimal commissionRate;
    private BigDecimal overtimeRate;
    private Boolean status;
    private LocalDateTime createTime;
    private LocalDateTime updateTime;
    
    public static SalarySchemeDTO fromEntity(SalaryScheme scheme) {
        SalarySchemeDTO dto = new SalarySchemeDTO();
        dto.setId(scheme.getId());
        dto.setName(scheme.getName());
        dto.setPositionId(scheme.getPositionId());
        dto.setSalaryType(scheme.getSalaryType().name());
        dto.setBaseSalary(scheme.getBaseSalary());
        dto.setPerformanceRate(scheme.getPerformanceRate());
        dto.setHourlyRate(scheme.getHourlyRate());
        dto.setCommissionRate(scheme.getCommissionRate());
        dto.setOvertimeRate(scheme.getOvertimeRate());
        dto.setStatus(scheme.getStatus());
        dto.setCreateTime(scheme.getCreateTime());
        dto.setUpdateTime(scheme.getUpdateTime());
        
        if (scheme.getPosition() != null) {
            dto.setPositionName(scheme.getPosition().getName());
        }
        
        return dto;
    }
} 